package cn.zane.domain.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: zane
 * @Date: 2025/04/05
 * @Description: 微信模板消息请求对象
 */
@Data
public class WeixinTemplateMessageVO {

    private String touser = "";

    private String template_id = "";

    private String url = "https://weixin.qq.com";

    private Map<String, Map<String, String>> data = new HashMap<>();

    public WeixinTemplateMessageVO(String touser, String template_id) {
        this.touser = touser;
        this.template_id = template_id;
    }

    public void put(TemplateKey key, String value) {
        data.put(key.getCode(), new HashMap<String, String>() {
            {
                put("value", value);
            }
        });
    }

    public static void put(Map<String, Map<String, String>> data, TemplateKey key, String value) {
        data.put(key.getCode(), new HashMap<String, String>() {
            {
                put("value", value);
            }
        });
    }


    @Getter
    @AllArgsConstructor
    @NoArgsConstructor
    public enum TemplateKey {

        USER("user", "用户ID");

        private String code;
        private String desc;
    }
}
